# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ttyd
pkgver=1.6.3
pkgrel=4
pkgdesc="Share your terminal over the web"
url="https://tsl0922.github.io/ttyd"
arch="all"
license="MIT"
depends="libwebsockets-evlib_uv"
makedepends="
	bsd-compat-headers
	cmake
	json-c-dev
	libuv-dev
	libwebsockets-dev
	openssl-dev
	samurai
	zlib-dev
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/tsl0922/ttyd/archive/$pkgver.tar.gz
	fix-cmake.patch
	"

build() {
	local crossopts=
	if [ "$CBUILD" != "$CHOST" ]; then
		crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=TRUE \
		$crossopts
	cmake --build build
}

check() {
	./build/ttyd --version
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="192b8b7216017b862e665a4ce2f89eef0499a6b2738d4dfffe8abd95b622c7f6729c9995adfd84d042fb3301e05fc6f58a458fe84f2ff2679deeb7e9efaf679f  ttyd-1.6.3.tar.gz
c489436c976c0a598763d3ebedcd42a7b3715b2c07967d74aaaad1fca345f85699f78ca3b62f0d810da0a1c91e868b8011cd3f9b62b5d5ad0a6185a8c5b6075f  fix-cmake.patch"
